package com.zh.note.demo.javaSE;

import java.util.Arrays;

/**
 * @Author: zhanghuan
 * @date: 2023/8/29 15:25
 * @description: 数组复制
 */
public class ArrayCopyDemo {
    public static void main(String[] args) {
        int[] nums = {1, 2, 3, 4, 5};
        int[] shifted = new int[5];

        System.arraycopy(nums, 0, shifted, 0, nums.length);

        int[] ints = Arrays.copyOf(nums, nums.length - 1);

        System.out.println(Arrays.toString(shifted));
        System.out.println(Arrays.toString(ints));

    }
}
